import 'dart:convert';

abstract class WechatResp {
  const WechatResp({
    required this.errorCode,
    this.errorMsg,
  });

  static const int kErrorCodeSuccess = 0;

  final int errorCode;
  final String? errorMsg;

  Map<String, dynamic> toJson();
}



class WechatAuthResp extends WechatResp {
  const WechatAuthResp({
    required super.errorCode,
    super.errorMsg,
    this.code,
    this.state,
    this.lang,
    this.country,
  });

  factory WechatAuthResp.fromJson(Map<String, dynamic> json) {
    return WechatAuthResp(
      errorCode: json['errorCode'] ?? WechatResp.kErrorCodeSuccess,
      errorMsg: json['errorMsg'],
      code: json['code'],
      state: json['state'],
      lang: json['lang'],
      country: json['country'],
    );
  }

  final String? code;
  final String? state;
  final String? lang;
  final String? country;

  @override
  Map<String, dynamic> toJson() {
    return {
      'errorCode': errorCode,
      'errorMsg': errorMsg,
      'code': code,
      'state': state,
      'lang': lang,
      'country': country,
    };
  }
}

class WechatOpenUrlResp extends WechatResp {
  const WechatOpenUrlResp({
    required super.errorCode,
    super.errorMsg,
  });

  factory WechatOpenUrlResp.fromJson(Map<String, dynamic> json) {
    return WechatOpenUrlResp(
      errorCode: json['errorCode'] ?? WechatResp.kErrorCodeSuccess,
      errorMsg: json['errorMsg'],
    );
  }

  @override
  Map<String, dynamic> toJson() {
    return {
      'errorCode': errorCode,
      'errorMsg': errorMsg,
    };
  }
}


class WechatShareMsgResp extends WechatResp {
  const WechatShareMsgResp({
    required super.errorCode,
    super.errorMsg,
  });

  factory WechatShareMsgResp.fromJson(Map<String, dynamic> json) {
    return WechatShareMsgResp(
      errorCode: json['errorCode'] ?? WechatResp.kErrorCodeSuccess,
      errorMsg: json['errorMsg'],
    );
  }

  @override
  Map<String, dynamic> toJson() {
    return {
      'errorCode': errorCode,
      'errorMsg': errorMsg,
    };
  }
}

class WechatSubscribeMsgResp extends WechatResp {
  const WechatSubscribeMsgResp({
    required super.errorCode,
    super.errorMsg,
    this.openId,
    this.templateId,
    this.scene,
    this.action,
    this.reserved,
  });

  factory WechatSubscribeMsgResp.fromJson(Map<String, dynamic> json) {
    return WechatSubscribeMsgResp(
      errorCode: json['errorCode'] ?? WechatResp.kErrorCodeSuccess,
      errorMsg: json['errorMsg'],
      openId: json['openId'],
      templateId: json['templateId'],
      scene: json['scene'],
      action: json['action'],
      reserved: json['reserved'],
    );
  }

  final String? openId;
  final String? templateId;
  final int? scene;
  final String? action;
  final String? reserved;

  @override
  Map<String, dynamic> toJson() {
    return {
      'errorCode': errorCode,
      'errorMsg': errorMsg,
      'openId': openId,
      'templateId': templateId,
      'scene': scene,
      'action': action,
      'reserved': reserved,
    };
  }
}

class WechatLaunchMiniProgramResp extends WechatResp {
  const WechatLaunchMiniProgramResp({
    required super.errorCode,
    super.errorMsg,
    this.extMsg,
  });

  factory WechatLaunchMiniProgramResp.fromJson(Map<String, dynamic> json) {
    return WechatLaunchMiniProgramResp(
      errorCode: json['errorCode'] ?? WechatResp.kErrorCodeSuccess,
      errorMsg: json['errorMsg'],
      extMsg: json['extMsg'],
    );
  }

  final String? extMsg;

  @override
  Map<String, dynamic> toJson() {
    return {
      'errorCode': errorCode,
      'errorMsg': errorMsg,
      'extMsg': extMsg,
    };
  }
}


class WechatOpenCustomerServiceChatResp extends WechatResp {
  const WechatOpenCustomerServiceChatResp({
    required super.errorCode,
    super.errorMsg,
  });

  factory WechatOpenCustomerServiceChatResp.fromJson(Map<String, dynamic> json) {
    return WechatOpenCustomerServiceChatResp(
      errorCode: json['errorCode'] ?? WechatResp.kErrorCodeSuccess,
      errorMsg: json['errorMsg'],
    );
  }

  @override
  Map<String, dynamic> toJson() {
    return {
      'errorCode': errorCode,
      'errorMsg': errorMsg,
    };
  }
}

class WechatOpenBusinessViewResp extends WechatResp {
  const WechatOpenBusinessViewResp({
    required super.errorCode,
    super.errorMsg,
    required this.businessType,
    this.extMsg,
  });

  factory WechatOpenBusinessViewResp.fromJson(Map<String, dynamic> json) {
    return WechatOpenBusinessViewResp(
      errorCode: json['errorCode'] ?? WechatResp.kErrorCodeSuccess,
      errorMsg: json['errorMsg'],
      businessType: json['businessType'],
      extMsg: json['extMsg'],
    );
  }

  final String businessType;
  final String? extMsg;

  @override
  Map<String, dynamic> toJson() {
    return {
      'errorCode': errorCode,
      'errorMsg': errorMsg,
      'businessType': businessType,
      'extMsg': extMsg,
    };
  }
}




class WechatOpenBusinessWebviewResp extends WechatResp {
  const WechatOpenBusinessWebviewResp({
    required super.errorCode,
    super.errorMsg,
    required this.businessType,
    this.resultInfo,
  });

  factory WechatOpenBusinessWebviewResp.fromJson(Map<String, dynamic> json) {
    return WechatOpenBusinessWebviewResp(
      errorCode: json['errorCode'] ?? WechatResp.kErrorCodeSuccess,
      errorMsg: json['errorMsg'],
      businessType: json['businessType'],
      resultInfo: json['resultInfo'],
    );
  }

  final int businessType;
  final String? resultInfo;

  @override
  Map<String, dynamic> toJson() {
    return {
      'errorCode': errorCode,
      'errorMsg': errorMsg,
      'businessType': businessType,
      'resultInfo': resultInfo,
    };
  }
}



class WechatPayResp extends WechatResp {
  const WechatPayResp({
    required super.errorCode,
    super.errorMsg,
    this.returnKey,
  });

  factory WechatPayResp.fromJson(Map<String, dynamic> json) {
    return WechatPayResp(
      errorCode: json['errorCode'] ?? WechatResp.kErrorCodeSuccess,
      errorMsg: json['errorMsg'],
      returnKey: json['returnKey'],
    );
  }

  final String? returnKey;

  @override
  Map<String, dynamic> toJson() {
    return {
      'errorCode': errorCode,
      'errorMsg': errorMsg,
      'returnKey': returnKey,
    };
  }
}